package com.qf.day10_3;

import java.util.Scanner;

/**
 * @author wgy
 * @version V1.0
 * @Project day10
 * @Package com.qf.day10_3
 * @Description: ${TODO}
 * @Date 2021/5/31 14:42
 */
public class TestManager {
    public static void main(String[] args) {
        //创建动物管理类
        Scanner input = new Scanner(System.in);
        AnimalManager manager = new AnimalManager();
        boolean flag=true;
        do {
            System.out.println("=============欢迎来到树桐动物园==============");
            System.out.println("========1.添加动物 2.查找动物 3.遍历动物 0.退出=========");
            System.out.println("请选择");
            int choice = input.nextInt();
            switch (choice) {
                case 1:
                    System.out.println("请输入动物昵称");
                    String nickname = input.next();
                    System.out.println("请输入动物品种");
                    String breed = input.next();
                    System.out.println("请输入动物颜色");
                    String color = input.next();
                    System.out.println("请输入动物年龄");
                    int age = input.nextInt();
                    Animal an = new Animal(nickname, breed, color, age);
                    boolean b = manager.add(an);
                    if (b) {
                        System.out.println("添加成功");
                    } else {
                        System.out.println("添加失败");
                    }
                    break;
                case 2:
                    System.out.println("请输入查找的动物昵称");
                    String nk=input.next();
                    Animal[] animals=manager.find(nk);
                    if(animals!=null){
                        for(Animal a : animals){
                            a.show();
                        }
                    }else{
                        System.out.println("没有找到");
                    }
                    break;
                case 3:
                    manager.list();
                    break;
                case 0:
                    flag=false;
                    break;
                default:
                    System.out.println("输入错误，请重新输入");
                    break;

            }
        }while(flag);
        System.out.println("欢迎下次光临");
    }
}
